{% extends "base.html" %}

{% block title %}用户管理{% endblock %}
{% block navbar %}
<section class="content-header">
    <h1>用户管理</h1>
    <ol class="breadcrumb">
        <li><i class="fa fa-dashboard"></i> 当前位置</li>
        <li class="active">系统设置</li>
        <li class="active">用户管理</li>
    </ol>
</section>
{% endblock %}

{% block content %}
<div class="box box-primary">
    <div class="box-header with-border">
        {% include 'message.html' %}
    </div>

    <div class="box-body">
        {% if objs%}
        <table class="table table-bordered">
            <tr>
                <th>ID</th>
                <th>用户名</th>
                <th>邮箱</th>
                <th>电话</th>
                <th>状态</th>
                <th>启用二次验证</th>
                <th>编辑</th>
                <th>删除</th>
            </tr>
            {% for row in objs %}
            <tr>
                <td>{{row.id}}</td>
                <td>{{row.username}}</td>
                <td>{{row.email}}</td>
                <td>{{row.phone}}</td>
                <td>{{row.status == True and '启用' or '停用'}}</td>
                <td>{{row.enable_otp == True and '启用' or '停用'}}</td>
                <td><a class='fa fa-lg fa-edit text-light-blue' href='{{url_for("main.useredit",id=row.id)}}'></a>
                </td>
                <td><a class='fa fa-lg fa-warning text-red' href='?action=del&id={{row.id}}'></a></td>
            </tr>
            {% endfor %}
        </table>
        {% endif %}
    </div>

    <div class="box-footer">
        <div class="col-md-12">
            <a class='btn btn-primary pull-right' href='{{ url_for("main.useredit") }}'>新建用户</a>
        </div>
    </div>

    <div class="box-footer clearfix">
        {% if objs%}
        <ul class="pagination pagination-sm no-margin pull-right">
            <li><a href="#">&laquo;</a></li>
            {% for i in range(1, total_page+ 1) %}
            {% if i == page %}
            <li><a href="?page={{i}}"><b>{{i}}</b></a></li>
            {% else %}
            <li><a href="?page={{i}}">{{i}}</a></li>
            {% endif %}
            {% endfor %}
            <li><a href="#">&raquo;</a></li>
        </ul>
        {% endif %}
    </div>
</div>
{% endblock %}

